negotiator.utility
Class EvaluatorDiscrete

java.lang.Object
  extended by negotiator.utility.EvaluatorDiscrete
All Implemented Interfaces:
Evaluator

public class EvaluatorDiscrete
extends java.lang.Object
implements Evaluator

This class is used to convert the value of a discrete issue to a utility. This object stores a mapping from each discrete value to a positive integer, the evaluation of the value. When asked for the utility of a value, the evaluation of the value is divided by the highest evaluation in the map. Note that this utility is not yet multiplied by the weight of the issue and therefore in the range [0,1].

Author:
Wouter Pasman

Constructor Summary
EvaluatorDiscrete()
          Creates a new discrete evaluator with weight 0 and no values.
 
Method Summary
 void addEvaluation(ValueDiscrete value, java.lang.Integer evaluation)
          Add a new possible value to the issue.
 void clear()
          wipe evaluation values.
 EvaluatorDiscrete clone()
           
 boolean equals(java.lang.Object obj)
           
 java.lang.Integer getEvalMax()
           
 java.lang.Double getEvaluation(UtilitySpace uspace, Bid bid, int issueID)
          Returns the evaluation of the value of the issue of the bid.
 java.lang.Double getEvaluation(ValueDiscrete value)
           
 java.lang.Integer getEvaluationNotNormalized(Bid bid, int ID)
           
 java.lang.Integer getEvaluationNotNormalized(ValueDiscrete value)
           
 Value getMaxValue()
           
 Value getMinValue()
           
 EVALUATORTYPE getType()
           
 java.lang.Integer getValue(ValueDiscrete value)
           
 java.util.Set<ValueDiscrete> getValues()
           
 double getWeight()
           
 int hashCode()
           
 java.lang.String isComplete(Objective whichobj)
          Check whether the evaluator has enough information to make an evaluation.
 void loadFromXML(negotiator.xml.SimpleElement pRoot)
          Method to
 void lockWeight()
          Locks the weight of this Evaluator.
 java.lang.Double normalize(java.lang.Integer EvalValueL)
           
 void setEvaluation(Value val, int evaluation)
          Sets the evaluation for Value val.
 void setWeight(double wt)
          Sets the weigth with which an Objective or Issue is evaluated.
 negotiator.xml.SimpleElement setXML(negotiator.xml.SimpleElement evalObj)
          Sets weights and evaluator properties for the object in SimpleElement representation that is passed to it.
 void unlockWeight()
          Unlock the weight of this evaluator.
 boolean weightLocked()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EvaluatorDiscrete

public EvaluatorDiscrete()
Creates a new discrete evaluator with weight 0 and no values.

Method Detail

getWeight

public double getWeight()
Specified by:
getWeight in interface Evaluator
Returns:
the weight for this evaluator, a value between 0 and 1.

setWeight

public void setWeight(double wt)
Description copied from interface: Evaluator
Sets the weigth with which an Objective or Issue is evaluated.

Specified by:
setWeight in interface Evaluator
Parameters:
wt - The new weight.

lockWeight

public void lockWeight()
Locks the weight of this Evaluator.

Specified by:
lockWeight in interface Evaluator

unlockWeight

public void unlockWeight()
Unlock the weight of this evaluator.

Specified by:
unlockWeight in interface Evaluator

weightLocked

public boolean weightLocked()
Specified by:
weightLocked in interface Evaluator
Returns:
The state of the weightlock.

getValue

public java.lang.Integer getValue(ValueDiscrete value)
Parameters:
value - of which the evaluation is requested.
Returns:
the non-normalized evaluation of the given value.

getEvalMax

public java.lang.Integer getEvalMax()
                             throws java.lang.Exception
Returns:
the largest evaluation value available
Throws:
java.lang.Exception - if there are no alternatives.

getEvaluation

public java.lang.Double getEvaluation(UtilitySpace uspace,
                                      Bid bid,
                                      int issueID)
                               throws java.lang.Exception
Returns the evaluation of the value of the issue of the bid.

Specified by:
getEvaluation in interface Evaluator
Parameters:
uspace - preference profile.
bid - of which we want a value evaluated.
issueID - unique id of the issue of which we want the evaluation.
Returns:
utility of the value for an issue, not normalized by the issue weight.
Throws:
java.lang.Exception - if problem, for instance illegal evaluation values.

getEvaluation

public java.lang.Double getEvaluation(ValueDiscrete value)
                               throws java.lang.Exception
Parameters:
value - of the issue.
Returns:
normalized utility (between [0,1]) of the given value.
Throws:
java.lang.Exception - if value is null.

getEvaluationNotNormalized

public java.lang.Integer getEvaluationNotNormalized(Bid bid,
                                                    int ID)
                                             throws java.lang.Exception
Parameters:
bid -
ID - of the issue of which we are interested in the value
Returns:
non-normalized evaluation (positive integer) of the given value.
Throws:
java.lang.Exception - if bid or value is null.

getEvaluationNotNormalized

public java.lang.Integer getEvaluationNotNormalized(ValueDiscrete value)
                                             throws java.lang.Exception
Parameters:
value - of the issue.
Returns:
non-normalized evaluation (positive integer) of the given value.
Throws:
java.lang.Exception - if value is null.

normalize

public java.lang.Double normalize(java.lang.Integer EvalValueL)
                           throws java.lang.Exception
Parameters:
EvalValueL -
Returns:
normalized EvalValue
Throws:
java.lang.Exception - if no evaluators or illegal values in evaluator. ASSUMED that Max value is at least 1, becaues EVERY evaluatordiscrete is at least 1.

getType

public EVALUATORTYPE getType()
Specified by:
getType in interface Evaluator
Returns:
type of evaluation function, for example EVALUATORTYPE.LINEAR.

setEvaluation

public void setEvaluation(Value val,
                          int evaluation)
                   throws java.lang.Exception
Sets the evaluation for Value val. If this value doesn't exist yet in this Evaluator, adds it as well.

Parameters:
val - The value to add or have its evaluation modified.
evaluation - The new evaluation.
Throws:
java.lang.Exception - if evaluation

clear

public void clear()
wipe evaluation values.


loadFromXML

public void loadFromXML(negotiator.xml.SimpleElement pRoot)
Description copied from interface: Evaluator
Method to

Specified by:
loadFromXML in interface Evaluator

setXML

public negotiator.xml.SimpleElement setXML(negotiator.xml.SimpleElement evalObj)
Sets weights and evaluator properties for the object in SimpleElement representation that is passed to it.

Parameters:
evalObj - The object of which to set the evaluation properties.
Returns:
The modified simpleElement with all evaluator properties set.

isComplete

public java.lang.String isComplete(Objective whichobj)
Description copied from interface: Evaluator
Check whether the evaluator has enough information to make an evaluation.

Specified by:
isComplete in interface Evaluator
Parameters:
whichobj - is the objective/issue to which this evaluator is attached.
Returns:
String describing lacking component, or null if the evaluator is complete.

addEvaluation

public void addEvaluation(ValueDiscrete value,
                          java.lang.Integer evaluation)
Add a new possible value to the issue.

Parameters:
value - to be added to the issue.
evaluation - of the value.

getMaxValue

public Value getMaxValue()
Returns:
value with the highest evaluation.

getMinValue

public Value getMinValue()
Returns:
value with the lowest evaluation.

clone

public EvaluatorDiscrete clone()
Specified by:
clone in interface Evaluator
Overrides:
clone in class java.lang.Object
Returns:
clone of the current object.

getValues

public java.util.Set<ValueDiscrete> getValues()
Returns:
valid values for this issue.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object